#include "MeshBuffer.hpp"
#include <iostream>

namespace Model {

MeshBuffer::MeshBuffer(const MeshRef &ref) : _mesh(ref) { Init(); }

MeshBuffer::~MeshBuffer() {}

void MeshBuffer::Init() {
  _buffer =
      Buffer::BufferPool::GetInstance().CreateABuffer(Buffer::BufferType::ARRAY_BUFFER);
  _buffer->AssignData(
      Buffer::BufferFormat(_mesh->GetBytes(),
                           /* TODO：获取数据类型 */ Model::DataType::FLOAT32,
                           GL_STREAM_DRAW),
      _mesh->GetBuffer());

  GLint param;
  glGetNamedBufferParameteriv(_buffer->GetID(), GL_BUFFER_SIZE, &param);
  std::cout << "Buffer Size: " << param << std::endl;
}

} // namespace Model